/**
 * 
 */
package info.pablo.maven.tulebox.example;

import java.util.Random;

import com.opensymphony.xwork2.ActionSupport;


/**
 * @author pablo_guerrero
 *
 */
public class Dice extends ActionSupport{
    private int diceType;
    private int result;
    
    /**
     * 
     */
    @Override
	public String execute()throws Exception{

		result = this.roll();
		return SUCCESS;
	
	}
    /**
     * Constructor
     * @param diceType
     */
    public Dice(int diceType) {
        this.diceType = diceType;
    }
    /**
     * Constructor
     */
    public Dice(){
    	this.diceType=6;
    }
    
    /**
     * 
     * @return random number
     */
    public int roll(){
    	Random rnd = new Random();
		int myresult=0;
		myresult = rnd.nextInt(getDiceType())+1;
		return myresult;
	}
	/**
	 * @return the diceType
	 */
	public int getDiceType() {
		return diceType;
	}
	/**
	 * @param diceType the diceType to set
	 */
	public void setDiceType(int diceType) {
		this.diceType = diceType;
	}
	/**
	 * @return the result
	 */
	public int getResult() {
		return result;
	}
	/**
	 * @param result the result to set
	 */
	public void setResult(int result) {
		this.result = result;
	}


		
}